<?php
/**
*	select
*/
namespace Rainrock\Framework\kernel\Html;

use Rainrock\Framework\kernel\base\Rock;

class HtmlSelect extends HtmlInput{
	
	public static function gets()
	{
		$obj = new HtmlSelect();
		$obj->setHeight(40);
		return $obj;
	}

	
	protected $label = 'select',$close = true,$css='input',$type='';
	
	
	protected function showBefore()
	{
		if(Rock::isempt($this->value)){
			$option = HtmlLabel::get('option');
			$option->addCont('-请选择-');
			$option->addAttrs('value','');
			$this->addCont($option);
		}
		$data = $this->data;
		$selected = -1;
		if($data)foreach($data as $k=>$rs){
			$option = HtmlLabel::get('option');
			$option->addCont($rs['name']);
			$option->addAttrs('value',$rs['value']);
			if($rs['value']==$this->value){
				$option->addAttrs('selected', 'true');
				$selected = $k;
			}
			$this->addCont($option);
		}
		if($selected == -1 && !Rock::isempt($this->value)){
			$option = HtmlLabel::get('option');
			$option->addCont('-请选择-');
			$option->addAttrs('selected', 'true');
			$option->addAttrs('value',$this->value);
			$this->addCont($option);
		}
		parent::showBefore();
	}
}